<div class="widget">
	<div class="widget-header bg-blue">
		<i class="widget-icon icon-notebook"></i> 
		<span class="widget-caption">推送通知 </span>
		<div class="widget-buttons">
			<a href="javascript:void(0);" onclick="handlerCancel(this);" title="关闭"
				 data-toggle="dispose" data-refresh-table="#table-notify"> <i class="fa fa-times"></i> </a> 
		</div>
	</div>
	<div class="widget-body">
		<!-- TODO 基本信息 -->
		<div class="widget radius-bordered">
			<div class="widget-header">
				<i class="widget-icon icon-notebook"></i> 
				<span class="widget-caption"> 基本信息 </span>
			</div>
			<div class="widget-body editor-body-sm">
				<form class="form-horizontal form-editor form-editor-notify">
					
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label " for="title">推送标题</label>
								<div class="col-sm-9">
									<select name="title" id="title" class="chosen-select" >
										<option value="蜜娃娃公告">蜜娃娃公告</option>
									</select>
								</div>
							</div>
						</div>

						<div class="col-sm-6">
							<div class="form-group">
								<label class="col-sm-3 control-label">推送机构</label>
								<div class="col-sm-9">
									<select id="shopSelect" class="chosen-select">
										
	              	</select>
	              </div>
	     				</div>
     				</div> 
   
					</div>
          
          <div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label" for="createDate">通知时间</label>
								<div class="col-sm-9">
									<div class="input-group date date-selector">
										<input name="createDate" id="createDate" type="text" class="form-control"> 
										<span class="input-group-addon">
											<span class="fa fa-calendar"></span>
										</span>
									</div>
								</div>
							</div>
						</div>
						<div class="col-sm-6">
							<div class="form-group">
          			<label class="col-sm-3 control-label">推送平台</label>
          			<div class="col-sm-9">
          				<ul class="list-inline">
		                <li>
		                  <label>
		                    <input id="id_aps" type="checkbox" checked="checked">
		                    <span>
		                      <i class="fa fa-apple"></i>
		                      <span> iOS</span>
		                    </span>
		                  </label>
		                </li>
		                <li>
		                  <label>
		                    <input id="id_android" type="checkbox" checked="checked">
		                    <span>
		                      <i class="fa fa-android" aria-hidden="true"></i>
		                      <span> Android</span>
		                    </span>
		                 	</label>
		               	</li>
	            		</ul>
          			</div>
          		</div>
          	</div>
					</div>
 
					<div class="row">
             <div class="col-sm-12">
							<div class="widget-header bordered-top ">
								<span class="widget-caption"> <font color="#f85d2c">推送内容</font> </span>
							</div>
							<div class="widget-body">
								<textarea id="message" name="message" class="form-control" required="required" rows="3" maxlength="58" placeholder="可输入58字"></textarea>
							</div>
						</div>
					</div>
					
					<div class="widget-footer editor-footer-sm">
						<button type="button" class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="取消" onclick="handlerCancel(this);" data-refresh-table="#table-notify">
							<i class="glyphicon glyphicon-remove"></i>
						</button>
						<button type="button" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="保存并发布" onclick="sendJpushMessage() ; handlerSubmit(this, '#editor-form-notify', '.form-editor-notify');">
							<i class="glyphicon glyphicon-ok"></i>
						</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<!-- 提交表单 ========================================================= -->
<form id="editor-form-notify" action="/miwawa/message/jpush" method="post" 
			name="org.framework.common.api.entity.CommonMessage" data-custom-action="true">
			<input type="hidden" name="userid">
			<input type="hidden" name="username">
			<input type="hidden" name="icon" value="fa fa-ball">
			<input type="hidden" name="status" value="0">
			<input type="hidden" name="invalid" value="F">
			<input type="hidden" name="info" id="info" >
</form>
    
<script type="text/javascript">
<!--
	jQuery(function() {

		jQuery(":hidden[name='userid']","#editor-form-notify").val(userid);
		jQuery(":hidden[name='username']","#editor-form-notify").val(username);
		getShops();
		
		require(['jquery.plugin.form'],function(form){
			form.datepicker('.date-selector',{format:'YYYY-MM-DD HH:mm:ss'});
			form.tooltip("[data-toggle='tooltip']");
			form.chosen("#title").select("#title",null,function(chosen){

			});
			
			form.chosen("#shopSelect").select("#shopSelect",null,function(chosen){

			});
		});

	});

	// 获取机构列表
	function getShops() {
		jQuery.ajaxsend({
      url:"/miwawa/default/common/search.json",
      data:{
          "entityClass":"com.app.miwawa.api.system.entity.view.ShopView",
          "and[0][operator]":"EQ",
          "and[0][fieldName]":"invalid",					// 删除标识
          "and[0][fieldValue]":"F",						// F=有效的<未删除>、T=无效的<已删除>
          "and[1][operator]":"EQ",
          "and[1][fieldName]":"status",					// 状态标识
          "and[1][fieldValue]":"0",						// 默认为0
          "and[2][operator]":"EQ",
          "and[2][fieldName]":"dbname",					    // 早教中心数据源
          "and[2][fieldValue]":dbname	// dbname
      },
      async:false,
      success : function(data) {
         var inner='';
         var dataList=data.rows;
         for(var i=0;i<dataList.length;i++){
             inner+='<option value="'+dataList[i].id +'">'+dataList[i].name+'</option>';
         }
         $("#shopSelect").html(inner);
      }
	  });
	}

	//发送jpush公告
	function sendJpushMessage() {
	    $("#info").val($("#shopSelect").val()); 
	}
	
//-->
</script>